package master.userInterface;

import java.awt.*;

import javax.swing.*;
import javax.swing.border.*;


import master.QuantumNetwork;
import master.event.NetworkEvent;
import master.event.NetworkEventListener;

public class NetworkScriptPanel extends JPanel implements NetworkEventListener{
	private final QuantumNetwork myNetwork;
	JTextArea myTextArea;
	NetworkButtonToolBar options;
	public NetworkScriptPanel(QuantumNetwork myNetwork){
		this.myNetwork = myNetwork;
		myNetwork.addNetworkListener(this);
		myTextArea= new JTextArea();
		myTextArea.setBorder(BorderFactory.createLineBorder(Color.GRAY));
		myTextArea.setEditable(true);
		myTextArea.setText(myNetwork.toString());
		
		options = new NetworkButtonToolBar(myNetwork, this);
		
		this.setLayout(new GridBagLayout());
		GridBagConstraints c = new GridBagConstraints();
		
		c.fill = GridBagConstraints.BOTH;
		c.weightx = 1;
		this.add(options,c);
		c.weighty = 1;
		c.gridy = 1;
		this.add(new JScrollPane(myTextArea),c);
	}
	
	public void networkEvent(NetworkEvent e) {
		myTextArea.setText(myNetwork.toString());
	}
	
	
}
